package ee.falcon.controller.profile;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Map;
import ee.falcon.gui.frame.ProfilesFrame;
import ee.falcon.xml.ProfileInfoXMLModifier;
import ee.falcon.xml.SpecificProfileInfo;

public class DeleteButtonListener implements ActionListener
{
	private ProfilesFrame profileFrame; 
	private ProfileInfoXMLModifier profileInfoXMLModifier; 
	private Map<String, SpecificProfileInfo> profileInfoHashMap; 
	
	public DeleteButtonListener(ProfilesFrame profileFrame, ProfileInfoXMLModifier profileInfoXMLModifier,
			Map<String, SpecificProfileInfo> profileInfoHashMap)
	{
		this.profileFrame = profileFrame; 
		this.profileInfoXMLModifier = profileInfoXMLModifier; 
		this.profileInfoHashMap = profileInfoHashMap; 
	}
	
	@Override
	public void actionPerformed(ActionEvent buttonEvent) 
	{
		profileInfoXMLModifier.deleteProfileFromProfileInfoXML(profileFrame.getSpecificProfileInfoJListSelection(), 
					 profileInfoHashMap);
		//renew GUI information
		profileFrame.getProfileInfoList().renewData();
		profileFrame.getProfilesFrameJListEditor().renewJListData();
	}
	
	//[START]GETTERS AND SETTERS
	public ProfilesFrame getProfilesFrame()
	{
		return this.profileFrame;
	}
	
	public ProfileInfoXMLModifier getProfileInfoXMLModifier()
	{
		return this.profileInfoXMLModifier; 
	}
	
	public Map<String, SpecificProfileInfo> getMapProfileInfoHashMap()
	{
		return this.profileInfoHashMap; 
	}
	//[END]GETTERS AND SETTERS
}
